﻿@model SoftHotel.Models.Usuario
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
 <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
   <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>    
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>


<h2>Create</h2>




 <script type="text/javascript">

     var linkObj;
     $(function () {
         $(".busqueda2").button();

         $('#searchDialog').dialog({
             autoOpen: false,
             width: 900,
             resizable: false,
             modal: true
             //            buttons: {
             //                
             //                "Cancel": function () {
             //                    $(this).dialog("close");
             //                }
             //            }
         });

         $(".busqueda2").click(function () {
             //change the title of the dialgo
             linkObj = $(this);
             var dialogDiv = $('#searchDialog');
             var viewUrl = linkObj.attr('href');
             $.get(viewUrl, function (data) {
                 dialogDiv.html(data);

                 //open dialog
                 dialogDiv.dialog('open');
             });
             return false;
         });

     });

     function searchSuccess() {
         var id = $("#update-message").html();
         //we update the table's info
         var parent = linkObj.closest("tr");
         document.getElementById('idTrabajador').value = $("#idTrabajador" + id.toString()).val();
         //  document.getElementById('nombreRazonSocial').value = $("#nombres" + id.toString()).val();

         // document.getElementById('numeroDocumento').value = $("#numDoc" + id.toString()).val();


         //now we can close the dialog
         $('#searchDialog').dialog('close');
     }
</script>

 <div id="searchDialog" title="Seleccionar Trabajador"></div>



@using (Html.BeginForm())
{   
    @Html.ValidationSummary(true)
     
    <table id="MainContent_Table1" rules="none" style="border-color: Black; width: 900px; margin-bottom: 0px;">
	<tbody><tr>
	  <td style="width: 20px;"></td>
	  <td style="font-weight: bold;">Trabajador Asociado</td>
	  <td> 
            @Html.TextBoxFor(model => model.idTrabajador)
           <a class="busqueda2" href="/Usuarios/BuscarTrabajador"> <img src="/Content/Images/buscar.png" alt="0" title="Buscar" id="" border="0" height="16" width="16"/></a>
     </td>
	  <td style="font-weight: bold;">Perfil </td>
	  <td><div class="editor-field">
            
            @Html.DropDownListFor(Model => Model.idPerfil, (IEnumerable<SelectListItem>)ViewBag.perfiles, "--seleccionar--")
        </div></td>
	</tr><tr>
	  <td style="width: 20px;"></td>
	  <td style="font-weight: bold;">Nombre de Usuario</td>
	  <td><div class="editor-field">
            @Html.TextBoxFor(model => model.nombre)
           
        </div> </td>
	  <td style="font-weight: bold;">Password</td>
	  <td><div class="editor-field">
            @Html.PasswordFor(model => model.password)
        </div></td>
	</tr>
	<tr>
	  <td style="width: 20px;"></td>
	  <td style="font-weight: bold;"></td>
	  <td></td>
	  <td style="font-weight: bold;"></td>
	  <td></td>
	</tr>
	<tr>
	  <td style="width: 20px;"></td>
	  <td style="font-weight: bold;"> </td>
	  <td><div class="editor-field">
          
        </div></td>
	  <td style="font-weight: bold; width: 145px;" align="left">&nbsp;</td>
	  <td style="width: 300px;">&nbsp;</td>
	</tr>
	
</tbody></table>
    <p>
    <input value="Guardar" type="submit" name = "button"/>
    </p>
}
